#include <iostream>
#include <string.h>
#include <getopt.h>

std::string name = "";
std::string age = "";

void parse(int argc, char * argv[])
{
    static const struct option long_option[] = {
       {"name", required_argument, 0, 0},
       {"age", required_argument, 0, 0},
       {0, no_argument, 0, 0}
    };
    std::string key;
    int option_index = 0;
    while(getopt_long(argc, argv, "", long_option, &option_index) != -1)
    {
        key = long_option[option_index].name;
        if(key.compare("name") == 0){
            name = optarg;
        }
        else if(key.compare("age") == 0){
            age = optarg;
        }
    }
}

int main(int argc, char * argv[])
{
    parse(argc, argv);
    std::cout << "name=" << name << std::endl;
    std::cout << "age=" << age << std::endl;
    return 0;
}
